import React, { Component } from 'react'
import { connect } from 'dva'
import { Row, Col, Button, Table, message, Modal } from 'antd'
import style from './index.css'
import {Link} from 'dva/router'

class IngList extends Component {
    //选择页码
    changePage =()=>{
        this.props.dispatch({
            type: 'repairManage/queryIng',
            payload: {
                size: 10,
                start: page
            }
        })
    }
    render() {
        const code = sessionStorage.getItem('code');
        const {ingList,allCount} = this.props.repairManage;
        console.log(ingList);
        console.log(allCount)
        const columns = code == 1 ? [
            {
                title:'序号',
                key:'orderBy',
                dataIndex:'orderBy',
            },{
                title:'报修名称',
                key:'repairname',
                dataIndex:'repairname',
            },{
                title:'创建时间',
                key:'cdate',
                dataIndex:'cdate',
            },{
                title:'接受时间',
                key:'rdate',
                dataIndex:'rdate',
            },{
                title:'操作员',
                key:'cname',
                dataIndex:'cname',
            }, {
                title: '详情',
                key: '1',
                render: (text, record) =>
                    <Link to={`/chzu/ingList/repairDetail/${record.rowguid}`} className={style.detail}>详情</Link>
            }
        ] : code == 2 ? [
                {
                    title: '序号',
                    key: 'orderBy',
                    dataIndex: 'orderBy',
                }, {
                    title: '报修名称',
                    key: 'repairname',
                    dataIndex: 'repairname',
                }, {
                    title: '学生姓名',
                    key: 'pname',
                    dataIndex: 'pname',
                },{
                    title: '创建时间',
                    key: 'cdate',
                    dataIndex: 'cdate',
                }, {
                    title: '接受时间',
                    key: 'rdate',
                    dataIndex: 'rdate',
                }, {
                    title: '详情',
                    key: '1',
                    render: (text, record) =>
                        <Link to={`/chzu/ingList/repairDetail/${record.rowguid}`} className={style.detail}>详情</Link>
                }
        ] : ''
        const rowSelection = {
            onChange: (selectedRowKeys, selectedRows) => {
                this.setState({
                    deleteId: selectedRows[0].rowguid
                })
            },
            getCheckboxProps: record => ({
                disabled: record.name === 'Disabled User',
                name: record.name,
            }),
        };
        return (
            <div className={style.content}>
                <Row>
                    <Col span={15} className={style.col}>
                        <span className={style.icon}>正在报修列表</span>
                    </Col>
                    <Col span={3} className={style.col}>           
                    </Col>
                    <Col span={3} className={style.col}>
                    </Col>
                    <Col span={3} className={style.col}>
                    </Col>
                </Row>
                <Table
                    rowKey='id'
                    rowSelection={rowSelection}
                    columns={columns}
                    dataSource={ingList}
                    pagination={{
                        total: allCount,
                        showTotal: total => `共有${allCount}条数据`,
                        onChange: this.changePage
                    }}
                />
            </div>
        )
    }
}
export default connect(({repairManage})=>({repairManage}))(IngList)
